import groupDao from "../dao/group";
import type {Group} from "../types";
import {getUuid,getCurrentTime,logger} from "../utils";


export async function queryList() {
    try {
        return await groupDao.queryList();
    } catch (error) {
        logger(error);
    }
}

export async function insert(data:Group){
    try {
        const rank = await groupDao.getRank()
        return await groupDao.insert({ ...data, id: getUuid(),createTime:getCurrentTime(),rank,status:0});
    } catch (error) {
        logger(error);
    }
}

export async function deleteById(id){
    try {
        return await groupDao.deleteById(id);
    } catch (error) {
        logger(error);
    }
}

export async function update(data :Group){
    try {
        return await groupDao.update(data);
    } catch (error) {
        logger(error);
    }
}
export default {
    queryList,
    insert,
    deleteById,
    update
};
